﻿<UserControl  xmlns:my="clr-namespace:System.Windows.Controls.WpfPropertyGrid;assembly=System.Windows.Controls.WpfPropertyGrid"  
    
             x:Class="devtm.Editor.Configuration.UCConfigEdit"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:c="clr-namespace:devtm.Editor.Configuration"
             mc:Ignorable="d" 
             xmlns:e="clr-namespace:devtm.Editor.Configuration.Messages"
             d:DesignHeight="332" d:DesignWidth="694" DataContext="{Binding}"
             xmlns:pg="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid"
             xmlns:local="clr-namespace:devtm.Editor.Configuration.MyEditors;assembly=devtm.Editor.Configuration"
             
             >
    
    <UserControl.Resources>
        
        <DataTemplate x:Key="ElementSectionDataTemplate">
            <Grid Margin="0,10,0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="35" />
                    <ColumnDefinition Width="200" />
                </Grid.ColumnDefinitions>
                <Image Source="/devtm.Editor.Configuration;component/Images/dossier.png" />
                <Label Grid.Column="1" Content="{Binding Name}" FontWeight="Bold" ToolTip="{Binding Description}" />
            </Grid>
        </DataTemplate>

        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

        <DataTemplate x:Key="{x:Static local:EditorKeys.FilePathPickerEditorKey}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBox Grid.Column="0" 
                 Text="{Binding StringValue}" 
                 IsReadOnly="True"
                 ToolTip="{Binding Value}"/>

                <Button Grid.Column="1" 
                        Margin="2,0,0,0" 
                        Content="..." 
                        Width="20"
                        Command="pg:PropertyEditorCommands.ShowDialogEditor"
                        CommandParameter="{Binding}" 
                        Visibility="{Binding IsEditable, 
                    Converter={StaticResource BooleanToVisibilityConverter}}"/>
               
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="{x:Static local:EditorKeys.ProtectPickerEditorKey}">
            <Grid>
                <ComboBox
                    SelectedItem="{Binding Value}"
                    ItemsSource="{x:Static local:EditorKeys.ListeProtect}" />
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    
    <Grid>

       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="300" MinWidth="300" />
           <ColumnDefinition Width="*" />
       </Grid.ColumnDefinitions>

       <Grid Grid.Column="0">
           <Grid.RowDefinitions>
               <RowDefinition Height="100*" />
               <RowDefinition Height="85*" />
           </Grid.RowDefinitions>
           
           <TreeView AllowDrop="True"
                      x:Name="TreeRoot" 
                      Grid.Row="0" 
                      SelectedItemChanged="TreeRoot_SelectedItemChanged" 
                      DragEnter="TreeRoot_DragEnter"
                      Drop="TreeRoot_Drop"
                      Margin="0,0,5,0"
                      KeyUp="TreeRoot_KeyUp" ItemsSource="{Binding}">
            </TreeView>

           <my:PropertyGrid 
                    Grid.Row="1" 
                    Margin="0,3,5,0" 
                    x:Name="MySectionProeperties" 
                    ShowAttachedProperties="True" 
                    ShowReadOnlyProperties="True"
                    PropertyDisplayMode="Native"
                    />

           <GridSplitter Grid.Row="1" ShowsPreview="True" Height="5" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Top" />

       </Grid>
       <Grid Grid.Column="1" x:Name="datacontainer" >
                <Grid.RowDefinitions>
                    <RowDefinition  />
                    <RowDefinition MaxHeight="80" />
                </Grid.RowDefinitions>
                
                <c:LstBox x:Name="myproperties" 
                          Width="{Binding ElementName=datacontainer, Path=Width}"
                          Grid.Row="0"
                          AllowDrop="True"
                          DragEnter="TreeRoot_DragEnter"                       
                          Drop="TreeRoot_Drop"
                          SelectionChangedEventHandler="SelectionChangedEventHandler" />

                <TextBlock Grid.Row="1" x:Name="LabelDescription" Padding="15" Background="Ivory">
    
                </TextBlock>
                
                <GridSplitter Grid.Row="1" ShowsPreview="True" Height="5" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
                
            </Grid>

        
       <GridSplitter ShowsPreview="True" Width="5" ResizeDirection="Columns" HorizontalAlignment="Right" VerticalAlignment="Stretch"  />

    </Grid>
    
</UserControl>
